using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;


namespace DAL
{
    public class Convertor
    {
        public static string  Hash(string s)
        {
            string ret = null;
            try
            {
                MD5 md = MD5.Create();

                ret = Convert.ToBase64String(md.ComputeHash(Encoding.Unicode.GetBytes(s.ToCharArray())));
            }
            catch{}

            return ret;
        }


        public static Guid ToGuid(string data)
        {
            try
            {
                return new Guid(data);
            }
            catch
            {
                return Guid.Empty;
            }
        }

        public static string ToString(Guid value)
        {
            return string.Format("{0}", value);
        }
    }
}
